package com.baor.web.controller.mall;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baor.common.annotation.Log;
import com.baor.common.core.controller.BaseController;
import com.baor.common.core.domain.AjaxResult;
import com.baor.common.enums.BusinessType;
import com.baor.mall.domain.TServe;
import com.baor.mall.service.ITServeService;
import com.baor.common.utils.poi.ExcelUtil;
import com.baor.common.core.page.TableDataInfo;

/**
 * 商品服务Controller
 * 
 * @author ruoyi
 * @date 2025-07-19
 */
@RestController
@RequestMapping("/mall/serve")
public class TServeController extends BaseController
{
    @Autowired
    private ITServeService tServeService;

    /**
     * 查询商品服务列表
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:list')")
    @GetMapping("/list")
    public TableDataInfo list(TServe tServe)
    {
        startPage();
        List<TServe> list = tServeService.selectTServeList(tServe);
        return getDataTable(list);
    }

    /**
     * 导出商品服务列表
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:export')")
    @Log(title = "商品服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TServe tServe)
    {
        List<TServe> list = tServeService.selectTServeList(tServe);
        ExcelUtil<TServe> util = new ExcelUtil<TServe>(TServe.class);
        util.exportExcel(response, list, "商品服务数据");
    }

    /**
     * 获取商品服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:query')")
    @GetMapping(value = "/{commoServeId}")
    public AjaxResult getInfo(@PathVariable("commoServeId") Long commoServeId)
    {
        return success(tServeService.selectTServeByCommoServeId(commoServeId));
    }

    /**
     * 新增商品服务
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:add')")
    @Log(title = "商品服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TServe tServe)
    {
        return toAjax(tServeService.insertTServe(tServe));
    }

    /**
     * 修改商品服务
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:edit')")
    @Log(title = "商品服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TServe tServe)
    {
        return toAjax(tServeService.updateTServe(tServe));
    }

    /**
     * 删除商品服务
     */
    @PreAuthorize("@ss.hasPermi('mall:serve:remove')")
    @Log(title = "商品服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commoServeIds}")
    public AjaxResult remove(@PathVariable Long[] commoServeIds)
    {
        return toAjax(tServeService.deleteTServeByCommoServeIds(commoServeIds));
    }
}
